package cn.iocoder.yudao.module.worker.dal.mysql.gift;

import java.util.*;

import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.worker.controller.app.gift.vo.AppWorkerGiftPageReqVO;
import cn.iocoder.yudao.module.worker.dal.dataobject.gift.WorkerGiftDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.worker.controller.admin.gift.vo.*;

/**
 * 礼物 Mapper
 *
 * @author Jerry
 */
@Mapper
public interface WorkerGiftMapper extends BaseMapperX<WorkerGiftDO> {

    default PageResult<WorkerGiftDO> selectPage(WorkerGiftPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<WorkerGiftDO>()
                .likeIfPresent(WorkerGiftDO::getName, reqVO.getName())
                .eqIfPresent(WorkerGiftDO::getGiftType, reqVO.getGiftType())
                .eqIfPresent(WorkerGiftDO::getTag, reqVO.getTag())
                .eqIfPresent(WorkerGiftDO::getImg, reqVO.getImg())
                .eqIfPresent(WorkerGiftDO::getPic, reqVO.getPic())
                .eqIfPresent(WorkerGiftDO::getMoney, reqVO.getMoney())
                .eqIfPresent(WorkerGiftDO::getWeigh, reqVO.getWeigh())
                .betweenIfPresent(WorkerGiftDO::getStartTime, reqVO.getStartTime())
                .betweenIfPresent(WorkerGiftDO::getEndTime, reqVO.getEndTime())
                .eqIfPresent(WorkerGiftDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(WorkerGiftDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(WorkerGiftDO::getId));
    }

    default PageResult<WorkerGiftDO> selectPage(AppWorkerGiftPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<WorkerGiftDO>()
                .likeIfPresent(WorkerGiftDO::getName, reqVO.getName())
                .eqIfPresent(WorkerGiftDO::getGiftType, reqVO.getGiftType())
                .eqIfPresent(WorkerGiftDO::getTag, reqVO.getTag())
                .eqIfPresent(WorkerGiftDO::getImg, reqVO.getImg())
                .eqIfPresent(WorkerGiftDO::getPic, reqVO.getPic())
                .eqIfPresent(WorkerGiftDO::getMoney, reqVO.getMoney())
                .eqIfPresent(WorkerGiftDO::getWeigh, reqVO.getWeigh())
                .betweenIfPresent(WorkerGiftDO::getStartTime, reqVO.getStartTime())
                .betweenIfPresent(WorkerGiftDO::getEndTime, reqVO.getEndTime())
                .eqIfPresent(WorkerGiftDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(WorkerGiftDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(WorkerGiftDO::getId));
    }

    default List<WorkerGiftDO> getGiftList(){
        return selectList(new LambdaQueryWrapperX<WorkerGiftDO>()
                .eqIfPresent(WorkerGiftDO::getStatus, true)
                .orderByDesc(WorkerGiftDO::getWeigh,WorkerGiftDO::getId));
    }

    default List<WorkerGiftDO> getAllGiftList(){
        return selectList(new LambdaQueryWrapperX<WorkerGiftDO>()
                .orderByDesc(WorkerGiftDO::getWeigh,WorkerGiftDO::getId));
    }
}